package lv.lu.events.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;

import lv.lu.events.interfaces.PersistentEntity;

@NamedQueries({
    @NamedQuery(name = JPQConst.UserJpq.QUERY_GET_USER_BY_USERNAME, 
		query = "SELECT u FROM User u WHERE u.username = :username"),
	@NamedQuery(name = JPQConst.UserJpq.QUERY_GET_ID_BY_USERNAME, 
        query = "SELECT u.id FROM User u WHERE u.username = :username")		
})

@Entity
public class User implements PersistentEntity {
	
	/**
	 * Persistent fields
	 */
	
	@Id @GeneratedValue
	private Long id;
	
	@Column(name="facebook_id")
	private String facebookId;
	
	private String username;
	
	private String password;
	
	private String fullName;
	
	private String email;
	
	// TODO [task] temporary marked as Transient, your task is to make this association persistent
	@Transient
	private List<Event> createdEvents;

	/**
	 * Getters and setters
	 */
	
	public Long getId() {
		return id;
	}	
	
	public String getFacebookId() {
		return facebookId;
	}

	public void setFacebookId(String facebookId) {
		this.facebookId = facebookId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<Event> getCreatedEvents() {
		return createdEvents;
	}

	public void setCreatedEvents(List<Event> createdEvents) {
		this.createdEvents = createdEvents;
	}
}
